<%@ page pageEncoding="UTF-8"%>
<%
	String ValiSkin = "default";
	if (session.getAttribute("user") instanceof ManageUser) {
	     ValiSkin = Tools.getDesc(((ManageUser)((ManageUser) session.getAttribute("user"))).getSkin(), "default");
	}
	request.setAttribute("skin", ValiSkin);
	//System.out.println(user.skin) ;
%>
<%try {%>
<link rel="stylesheet" href="/skin/${user.skin}/css/left_menu.css?cache=<%=Math.random()%>"/>
<%} catch (Exception e) {
	out.println("txzj/css/left_menu.css?cache="+ Math.random() + "/\">"
	);
}%>

<div class="left_menu" id="left_menu">
    <dl>
        <a href="/index.jsp">

        </a>
        <template v-for="item in menus">
            <div class="left_menu_hospital" @click="jump(item.url)" :class="{'children': !item.url}">
                <span class="iconfont iconfontfile">
                    <img :src="'/skin/' + skin + '/images/' + item.icon"/>
                </span>
                <span class="left_menu_main_span" v-html="item.name"></span>
            </div>
            <dd class="dd_one" v-if="!item.url">
                <a @click="jump(subItem.url)" v-for="subItem in item.childs">
                    <li class="index_jump bg_no" id="{{subItem.url | replaceSome}}" v-html="subItem.name"></li>
                </a>
            </dd>
        </template>
    </dl>
</div>
<script type="text/javascript">
	Vue.filter("replaceSome", function(value) {
		return value.replace("/", "").replace("/", "").replace("/", "").replace(".", "");
    });
    var menus = Object.freeze({
        power: <%=JSONUtil.toJson((List<Privilege>)session.getAttribute("menus"))%>
    });
    new Vue({
        el: "#left_menu",
        data: {
            skin: "${skin}",
            menus: menus.power,
        },
		methods: {
			jump: function(url) {
				if (!url) {
					return;
				}
				// 清除所有的参数缓存
                clearAllHrefParms();
				location.href = url;
			}
		},
        ready: function() {

        }
    });

</script>
<script>
    $('dd').hide();
    $('.left_menu_hospital.children').click(function() {
        $(this).next().slideToggle(100).siblings("dd:visible").slideUp(100);
    })
 </script>
 <%
	String csspPath = input.getPath();
	List<Privilege> selectPrivs = (List<Privilege>)session.getAttribute("menus");
	boolean csspPathExists = false;
	for (Privilege p:selectPrivs) {
		List<Privilege> subItems = p.getChilds();
		for (Privilege sub:subItems) {
			if (Tools.getDesc(sub.getUrl()).equals(csspPath))
				csspPathExists = true;
		}
	}
	if (!csspPathExists) {
		for (Privilege p:selectPrivs) {
			List<Privilege> subItems = p.getChilds();
			for (Privilege sub:subItems) {
				for (Privilege third:sub.getChilds()) {
					if (Tools.getDesc(third.getUrl()).equals(csspPath)) {
						csspPath = Tools.getDesc(sub.getUrl());
						break;
					}
				}
			}
		}
	}
	csspPath = csspPath.replaceAll("/", "").replaceAll("\\.", "");
 %>
 <script>
    $('.bg_no').addClass('left_menu_default');
    $('#<%=csspPath%>').addClass('left_menu_checked');
    $('#<%=csspPath%>').parent().parent().show()
 </script>
